<?php

require('config.php');
$language_link=$_GET['id'];
if($language_link != null && $language_link > 0 ) {
	$content = modelPage::getObject($language_link);
	if(!$content)redirectFront(index);
}else{
	redirectFront(index);
}
$html_name = $content->url_rewriting.'-'.$language_link.'.html';

	/*if($content){
		if(!$_GET['preview']){
			if($content->id_in_tree != null and $content->id_in_tree > 0){
				if($content->status_connection == STATUS_NEED_CONNECTION){
					if(!isset($_SESSION['id_user'])){
						$_SESSION['referer_connexion'] =  "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
						redirectFront('connexion');
					}
				}
			}else{
				redirectFront('connexion');
			} 
		}
	}else{
		redirectFront('index');
	}*/

$page = new rootLayoutPage();
//$page->addJavaScript('jquery.fancybox-1.2.1.js');
//$page->addJavaScript('video.js');
$page->setPageSameLevel($content->id_menu_left_tree);
//-- Menu Page ----------------------------------------------//
$menu = new layoutMenuLeft();
	$menuPage = new layoutMenuPage();
	$menuPage->setTable('content_page');
	$menuPage->setIdShow($content->id_menu_left_tree);
	$menu->setIdShow($content->id_menu_left_tree);
	$menu->pushMenu($menuPage);

//--------Menu indicator--------------//
$menuIndictor = new layoutMenuIndicator();
	$menuIndictor->idTree($content->id_menu_left_tree);
	$menuIndictor->title($content->title);
	$page->setMenuIndicator($menuIndictor);

//************************//
$arr = array();
$getListUrlPage = modelPage::getListUrlPage($language_link);
foreach($getListUrlPage AS $key=>$Url){
	$arr[$Url->language_code]=$Url->url_rewriting.'-'.$Url->language_link.'.html';
}
$header = new layoutHeader();
$header->setArrayUrl($arr);
$header->setIdShow($content->id_menu_left_tree);
$header->setIdOutTree($content->id_in_tree);
$page->setHeader($header);

$page->setMenuPage($menu);
$page->setBaliseTitle($content->meta_title);
$page->setDescription($content->meta_description);
$extension = filename_extension($_SERVER['REQUEST_URI']);
$page->setCanonical($html_name);

$Body = new flyLayout(REP_TPL . 'page.tpl');
$Body->start();
/*	if($content->attraction==1){
		$Body->showBlock('attraction');
	}else{*/
		preg_match('/\.\.\./',$content->title,$match_origin);
		preg_match('/\.\.\./',affiche($content->title,'sort_title_news'),$match);
		if(isset($match_origin[0])){
			if($match_origin[0] !='...'){
			$show_title_news = $match[0]=='...'?$content->title:'';
		}
		}
		$Body->setVariable('nom_page_title', affiche($content->title,'sort_title_news'));
		$Body->showBlock('title_page');
	//}

	$page->setIndex($content->index);
	$page->setFollow($content->follow);

	$newContent = affiche($content->contenu, 'tcode');
/*	if($content->borne_gauche&&$content->borne_droite){
		$ordre = modelMenuLeft::getFatherLevelOne($content->borne_gauche,$content->borne_droite)->ordre;
		if($ordre>0 ){
			$Body->setVariable('page_class',$ordre>40?10:$ordre);
		}else{
			$Body->setVariable('page_class',$content->ordre>40?10:$content->ordre);
		}
	}*/
	$Body->setVariable('page',$newContent);

$Body->stop();
$page->setBody($Body);
$page->display();

?>